<template>
  <div class="app-container" v-if="this.tableData.length >0">
    <div style="display: flex;flex-flow: row nowrap;margin-left: 9%">
      <div style="border:1px;background-color: #4e8dff; width: 6px;height: 20px"></div>
      <span style="margin-left: 10px;margin-bottom: 20px">审核记录</span>
    </div>

    <el-table :data="tableData" style="width: 85%;margin-left: 100px">
      <el-table-column label="操作人" align="center" prop="apprUserName"></el-table-column>
      <el-table-column v-if="opreationType >0" label="操作人类型" align="center" prop="apprUserType">
        <template slot-scope="scope">
          {{ getApprUserType(scope.row.apprUserType) }}
        </template>
      </el-table-column>
<!--      <el-table-column label="操作类型" v-if="opreationType >0" align="center" prop="opreationType">-->
<!--        <template slot-scope="scope">-->
<!--          {{ getOpreationType(scope.row.opreationType) }}-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="操作结果" align="center" prop="apprResult">
        <template slot-scope="scope">
          {{ getApprResult(scope.row.apprResult) }}
        </template>
      </el-table-column>
      <el-table-column label="审核意见" align="center" prop="apprOppinion" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column label="操作时间" align="center" prop="createTime"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import {listApprHistory} from "@/api/examine/history/api";

export default {
  name: 'ApprRecords',
  props: {
    examineId: String,
    // 是否是考评
    opreationType:Number
  },
  dicts: ['appr_opreation_type', 'examine_appr_state', 'sys_user_category'],
  data() {
    return {
      tableData: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      if (this.examineId) {
        listApprHistory({examineId: this.examineId,opreationType:this.opreationType}).then(resp => {
          this.tableData = resp.rows
        })
      }
    },
    getApprResult(data) {
      if (data !== null) {
        var obj = this.dict.type.appr_opreation_type.find(d => d.value === String(data))
        if (obj) {
          return obj.label
        }
      }
    },
    getApprUserType(data) {
      if (data !== null) {
        if(data.indexOf(",")  === -1){
          var obj = this.dict.type.sys_user_category.find(d => d.value === String(data))
          if (obj) {
            return obj.label
          }
        }else{
          var arr= data.split(",")
          var showArr=[]
          arr.forEach(f=>{
            var obj = this.dict.type.sys_user_category.find(d => d.value === f)
            if (obj) {
             showArr.push(obj.label)
            }
          })
          if(showArr.length >0){
            return  showArr.join(",")
          }else{
            return ""
          }
        }
      }
    },
    getOpreationType(data) {
      var obj = [{id: 0, name: '任务审核'}, {id: 1, name: '培训审核'}, {id: 2, name: '考评审核'}]
      var temp= obj.find(d => d.id === data)
      if(temp){
        return temp.name
      }
    }
  }
}
</script>
